package Filter;

import java.util.List;

public class OrCriteria implements  Criteria{
    private  Criteria firstCriteria;
    private  Criteria secondCriteria;
    public  OrCriteria(Criteria firstCriteria,Criteria secondCriteria) {
        this.firstCriteria=firstCriteria;
        this.secondCriteria=secondCriteria;
    }
    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        List<Person> people=firstCriteria.meetCriteria(persons);
        List<Person> personList=secondCriteria.meetCriteria(persons);
        personList.forEach((o)->{
            if(!people.contains(o))
                people.add(o);
        });
        return people;
    }
}
